package com.itheima.Jiuye14;

public class Zuoye3 implements Runnable {
    private int a =1000;
    @Override
    public void run() {
        while (true){
            synchronized (this){
                if (a <= 0){
                    break;
                }else {
                    try {
                        Thread.sleep(3000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    a--;
                    System.out.println(Thread.currentThread().getName()+"在卖票，还剩"+a+"张票");
                }
            }
        }
    }
}
